package com.marktotop.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Swagger2Config
 *
 * @author WXLD
 * @Data 2021/7/3
 * @Since 1.0
 */
@Configuration
@EnableSwagger2
public class Swagger2Config {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                //分组名称
                .select()
//                .apis(RequestHandlerSelectors.any())// 对所有api进行监控
                .apis(RequestHandlerSelectors.basePackage("com.marktotop"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("SpringCloud微服务架构体系学习")
                .description("SpringCloud微服务架构体系")
                .description("主要技术栈：Mybatis-Plus、Security、druid、Swagger2、FastDFS")
                .version("1.0")
                .contact(new Contact("MarkToTop","http://www.marktotop.cn","Marktotop@163.com"))
                .license("Home")
                .licenseUrl("http://localhost:8001/swagger-ui.html")
                .build();
    }
}